import crypto from 'crypto'
const iv = '123@qwe'

export const fun = (query, request) => {
  const stu = query.stu
  const answer = {
    cookie: stu
  }
  const timestamp = (new Date().getTime() / 1000).toFixed()
  const hash = crypto.createHash('md5')
  hash.update(iv)
  hash.update(stu)
  hash.update(timestamp.substring(0, 5) + '0000')
  return new Promise((resolve, reject) => {
    // const d = crypto.SHA256(timestamp + token + nonce + timestamp)
    //   .toString(crypto.enc.Hex)
    //   .toUpperCase()
    answer.body = hash.digest('hex')
    resolve(answer)
  })
}

export const signa = cookie => {
  const timestamp = (new Date().getTime() / 1000).toFixed()
  const hash = crypto.createHash('md5')
  hash.update(iv)
  hash.update(cookie)
  hash.update(timestamp.substring(0, 5) + '0000')
  return hash.digest('hex')
}

export const name = query => {
  return new Promise((resolve, reject) => {
    resolve({
      msg: process.hx
    })
  })
}
